home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / news / inn-1.4-l / inn-1 / inn-1.4-linux-0.1 / inn-patches / inn-1.4-ctlinnd-patch
Internet Message Format  |  1993-08-15  |  5KB

  1. From adv.win.tue.nl!svin09.info.win.tue.nl!tuegate.tue.nl!sun4nl!mcsun!uunet!charon.citicorp.com!charon.citicorp.com!not-for-mail Sun Aug 15 20:18:37 GMT 1993
  2. Article: 1541 of news.software.nntp
  3. Path: adv.win.tue.nl!svin09.info.win.tue.nl!tuegate.tue.nl!sun4nl!mcsun!uunet!charon.citicorp.com!charon.citicorp.com!not-for-mail
  4. From: philip@charon.citicorp.com (Philip Gladstone)
  5. Newsgroups: news.software.nntp
  6. Subject: Patch to fix ctlinnd hang if no Unix Domain Sockets
  7. Date: 14 Aug 1993 15:26:32 -0400
  8. Organization: Citicorp
  9. Lines: 141
  10. Distribution: inet
  11. Message-ID: <24je98$anr@charon.citicorp.com>
  12. Reply-To: Philip.Gladstone@mail.citicorp.com
  13. NNTP-Posting-Host: charon.citicorp.com
  14. X-Newsreader: TIN [version 1.2 PL1]
  15.  
  16. The following is a patch to fix the problem of multiple ctlinnd
  17. processes interfering with each other. This problem arises on
  18. system which do not use Unix Domain Sockets. The problem normally
  19. arises when a bunch of 'newgroup' messages come out at the same
  20. time. Only the first one works -- all the rest fail.
  21.  
  22. Philip.
  23.  
  24.  
  25. *** lib/inndcomm.c.orig    Fri Aug 13 13:44:24 1993
  26. --- lib/inndcomm.c    Sat Aug 14 15:12:54 1993
  27. ***************
  28. *** 169,175 ****
  29. --- 169,186 ----
  30.   
  31.   /*
  32.   **  Send an arbitrary command to the server.
  33. + **  Note that for those systems without Unix Domain Sockets,
  34. + **  the command format is different. There is a two byte
  35. + **  length code on the front of the message. This is a
  36. + **  direct mapped integer. Note that sending and receiving
  37. + **  architectures *must* be the same as we are on the same
  38. + **  machine.
  39.   */
  40. + #if defined(DO_HAVE_UNIX_DOMAIN)
  41. + #define BUFF_OFFSET 0
  42. + #else
  43. + #define BUFF_OFFSET sizeof(ICC_MSGLENTYPE)
  44. + #endif
  45.   int
  46.   ICCcommand(cmd, argv, replyp)
  47.       char        cmd;
  48. ***************
  49. *** 203,209 ****
  50.       bufsiz += 1 + strlen(p);
  51.       if (bufsiz < MIN_BUFFER_SIZE)
  52.       bufsiz = MIN_BUFFER_SIZE;
  53. !     buff = malloc((unsigned int)bufsiz);
  54.       if (buff == NULL) {
  55.       ICCfailure = "malloc";
  56.       return -1;
  57. --- 214,220 ----
  58.       bufsiz += 1 + strlen(p);
  59.       if (bufsiz < MIN_BUFFER_SIZE)
  60.       bufsiz = MIN_BUFFER_SIZE;
  61. !     buff = malloc((unsigned int)bufsiz + BUFF_OFFSET);
  62.       if (buff == NULL) {
  63.       ICCfailure = "malloc";
  64.       return -1;
  65. ***************
  66. *** 211,216 ****
  67. --- 222,229 ----
  68.       if (replyp)
  69.       *replyp = NULL;
  70.   
  71. +     buff += BUFF_OFFSET;    /* Advance to leave space for length */
  72.       /* Format the message. */
  73.       (void)sprintf(buff, "%s%c%c", ICCsockname, SC_SEP, cmd);
  74.       for (p = buff + strlen(buff), i = 0; (q = argv[i]) != NULL; i++) {
  75. ***************
  76. *** 221,226 ****
  77. --- 234,243 ----
  78.       /* Send message. */
  79.       ICCfailure = NULL;
  80.       len = p - buff;
  81. +     buff -= BUFF_OFFSET;    /* Not strictly required - could be inside
  82. +                  * #else clause below */
  83.   #if    defined(DO_HAVE_UNIX_DOMAIN)
  84.       if (sendto(ICCfd, buff, len, 0,
  85.           (struct sockaddr *)&ICCserv, AF_UNIX_SOCKSIZE(ICCserv)) < 0) {
  86. ***************
  87. *** 234,239 ****
  88. --- 251,258 ----
  89.       ICCfailure = "open";
  90.       return -1;
  91.       }
  92. +     *(ICC_MSGLENTYPE *) buff = len;
  93. +     len += BUFF_OFFSET;
  94.       if (write(fd, buff, len) != len) {
  95.       i = errno;
  96.       DISPOSE(buff);
  97. *** include/inndcomm.h.orig    Sat Aug 14 15:09:12 1993
  98. --- include/inndcomm.h    Sat Aug 14 15:14:44 1993
  99. ***************
  100. *** 4,9 ****
  101. --- 4,15 ----
  102.   **  running.
  103.   */
  104.   
  105. + #if !defined(DO_HAVE_UNIX_DOMAIN)
  106. + typedef short ICC_MSGLENTYPE;    /* Length code to prefix commands to
  107. +                 ** the server.
  108. +                 */
  109. + #endif
  110.   #define SC_SEP        '\001'
  111.   #define SC_MAXFIELDS    6
  112.   
  113. *** innd/cc.c.orig    Fri Aug 13 13:51:22 1993
  114. --- innd/cc.c    Sat Aug 14 15:13:52 1993
  115. ***************
  116. *** 1314,1319 ****
  117. --- 1314,1320 ----
  118.       struct sockaddr_un    client;
  119.   #else
  120.       int            written;
  121. +     ICC_MSGLENTYPE    bufflen;
  122.   #endif    /* defined(DO_HAVE_UNIX_DOMAIN) */
  123.       int            i;
  124.       char        buff[BUFSIZ + 2];
  125. ***************
  126. *** 1329,1335 ****
  127. --- 1330,1350 ----
  128.       }
  129.   
  130.       /* Get the message. */
  131. + #if !defined(DO_HAVE_UNIX_DOMAIN)
  132. +     i = RECVorREAD(CCchan->fd, (char *) &bufflen, sizeof(bufflen));
  133. +     if (i != sizeof(bufflen) 
  134. +     || bufflen < 1 || bufflen >= (sizeof buff - 1)) {
  135. +     syslog(L_ERROR, "%s cant recv CCreader length %m", LogName);
  136. +     return;
  137. +     }
  138. +     i = RECVorREAD(CCchan->fd, buff, bufflen);
  139. +     if (i > 0 && i != bufflen) {
  140. +     syslog(L_ERROR, "%s cant recv CCreader data %m", LogName);
  141. +     return;
  142. +     }
  143. + #else
  144.       i = RECVorREAD(CCchan->fd, buff, sizeof buff - 1);
  145. + #endif
  146.       if (i < 0) {
  147.       syslog(L_ERROR, "%s cant recv CCreader %m", LogName);
  148.       return;
  149. -- 
  150. Philip Gladstone - Consultant
  151. Citicorp Global Information Network
  152. I don't speak for Citicorp. I presume that somebody else does!
  153.  
  154.  
  155.